package com.leetcode.partition8;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/23 21:46
 */
public class LC729我的日程安排表I {

    private static SegmentTree root;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int m = Integer.parseInt(reader.readLine());
        myCalendar();
        while (m-- > 0) {
            String[] ss = reader.readLine().split(" ");
            int l = Integer.parseInt(ss[0]), r = Integer.parseInt(ss[1]);
            writer.write(book(l, r) + "\n");
            writer.flush();
        }
        writer.flush();
    }

    public static void myCalendar() {
        root = new SegmentTree(-1, -1);
    }

    public static boolean book(int start, int end) {
        return modify(root, start, end - 1);
    }

    private static boolean modify(SegmentTree root, int l, int r) {
        SegmentTree cur = root;
        while (true) {
            if (r < cur.l) {
                if (cur.lc == null) {
                    cur.lc = new SegmentTree(l, r);
                    return true;
                }
                cur = cur.lc;
            } else if (l > cur.r) {
                if (cur.rc == null) {
                    cur.rc = new SegmentTree(l, r);
                    return true;
                }
                cur = cur.rc;
            } else return false;
        }
    }

    private static class SegmentTree {
        private int l, r;
        private SegmentTree lc, rc;

        public SegmentTree(int l, int r) {
            this.l = l;
            this.r = r;
        }
    }
}
